/**
 * 
 */
package com.edocbase.desktop.plugins.driver;

import org.eclipse.draw2d.ActionEvent;
import org.eclipse.draw2d.ActionListener;

import com.edocbase.biz.diary.entities.WebAccount;
import com.edocbase.desktop.maildriver.DriverWorker;
import com.edocbase.webdriver.DriverException;

/**
 * @author lifei114@gmail.com
 *
 */
public class ReceiveMailAction implements ActionListener {
	private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
			.getLogger(ReceiveMailAction.class);
	private DriverComposite driverComposite = null;
	
	public ReceiveMailAction(DriverComposite driverComposite) {
		super();
		this.driverComposite = driverComposite;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.draw2d.ActionListener#actionPerformed(org.eclipse.draw2d.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent event) {
		WebAccount account = driverComposite.getSelectedAccount();
		if (logger.isDebugEnabled()) {
			logger.debug("action receive mail ...." + account);
		}
		if (account == null){
			return;
		}
		
		DriverWorker worker = DriverWorker.getWorker();
		try {
			worker.receive(account);
		} catch (DriverException e) {
			e.printStackTrace();
		}
		
	}

}
